#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int a[N];
vector<int> bian[N];
bool open[N];
int fst[N],sed[N];
int rnk[N*2];
int ti;
void dfs(int x,int fa){
    fst[x] = ++ti;
    rnk[ti] = x;
    for(int v:  bian[x]){
        if(v == fa){
            continue;
        }
        dfs(v,x);
    }
    sed[x] = ++ti;
    rnk[ti] = x;
}
int tong[N];
int ans;
void update(int p){
    if(open[p]){
        tong[a[p]]++;
    }
    
}
int ac[N];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i = 1;i<=n;i++){
        cin>>a[i];
        ac[i] = a[i];
    }
    sort(ac + 1,ac + 1 + n);
    int tot = unique(ac + 1,ac + 1 + n) - ac - 1;
    for(int i = 1;i<=n;i++){
        a[i] = lower_bound(ac + 1,ac + 1 + tot,a[i]) - ac;
    }
    for(int i = 2;i <= n;i++){
        int u,v;
        cin>>u>>v;
        bian[u].push_back(v);
        bian[v].push_back(u);
    }
    for(int i = 1;i<=m;i++){
    }
}